/**
 * FlightInfoDbMngrImpl.java
 * Jan 11, 2010
 */
package com.dlplay.flightinfo.db;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.jdo.annotations.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import org.datanucleus.Transaction;



import com.dlplay.flightinfo.core.SimpleFlightManager;
import com.dlplay.flightinfo.data.AirFlightCode;
import com.dlplay.flightinfo.data.AirlineCode;
import com.dlplay.flightinfo.data.Airport;
import com.dlplay.flightinfo.data.AirportTerminalCode;
import com.dlplay.flightinfo.data.CityCode;
import com.dlplay.flightinfo.data.EMailRegister;
import com.dlplay.flightinfo.data.FlightInfo;
import com.dlplay.flightinfo.data.RealTimeFlightInfo;
import com.dlplay.flightinfo.data.FlightRegInfo;
import com.dlplay.flightinfo.data.Weather;
import com.dlplay.flightinfo.db.business.AirportEntity;
import com.dlplay.flightinfo.db.business.AirportQuery;
import com.dlplay.flightinfo.db.business.FlightEntity;
import com.dlplay.flightinfo.db.business.FlightQuery;
import com.dlplay.flightinfo.db.datastore.EMF;

/**
 * @author zhao yu
 *
 */
public class FlightInfoDbMngrImpl implements FlightInfoDbMngr {
	private static final Logger log = Logger.getLogger(FlightInfoDbMngrImpl.class.getName());		

	@Override
	public void addAirport(Airport airport) {
		log.info("add new airport "+airport);
		
	}

	@Override
	public void addFlightRegister(EMailRegister reg) {
		log.info("register: "+reg);
		
	}

	@Override
	public void addRealTimeFlightInfo(RealTimeFlightInfo rtFlightInfo) {
		log.info("info: "+rtFlightInfo);		
		log.info("add a new record");
		
	}

	@Override
	public void deleteAirport(AirportTerminalCode terminal) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Airport getAirport(AirportTerminalCode terminal) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Airport> getAirports() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public EntityManager getEntityManager() {		 
		return EMF.getEntityManager(); 
	}

	@Override
	public EMailRegister getFlightEmailRegister(AirFlightCode flightNum,
			String email) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FlightInfo> getFlightInfo(CityCode from, CityCode to, Date date) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public FlightInfo getFlightInfo(AirFlightCode flightNumber, Date date) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public RealTimeFlightInfo getRealTimeFlightInfo(AirFlightCode flightNumber) {
		log.info("find flight: "+flightNumber);
		//TODO search the data in DB
		RealTimeFlightInfo ret = null;
		if(flightNumber.equals(new AirFlightCode(AirlineCode.CA, 1585)))
		{
			ret = new RealTimeFlightInfo(flightNumber);
		}
		else
		{
			ret = null;
		}
		return ret;
	}

	@Override
	public List<AirFlightCode> getRegisteredFlights() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateAirport(Airport airport) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateRealTimeFlightInfo(RealTimeFlightInfo info) {
		// TODO Auto-generated method stub
		
	}	

}
